import os
import time
import unittest
from HTMLTestRunner import HTMLTestRunner

# 加载测试用例
suite = unittest.defaultTestLoader.discover('case','*_case.py')

# 准备测试报告存放地址
report_path = os.path.dirname(__file__)

file_path = os.path.join(report_path,time.strftime('%y%m%d%H%M%S') + '-测试报告.html')

# 以二进制方式创建并打开文件句柄，并执行用例生成测试报告
with open(file_path,'wb') as f:
    runner = HTMLTestRunner(
        title='ECshop',
        description='ECshop自动化测试报告',
        stream=f,
        verbosity=2,
        tester='蒋望舒，孙曹人，钟伟杰',
    )
    runner.run(suite)